package org.xielei.base;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * StringTest
 *
 * @author xielei
 * @date 2020/11/26
 */
public class StringTest {

    @Test
    public void jsonStringTest() {
        String channelCode = "test_1234";
        String jsonString = JSON.toJSONString("channelCode=" + channelCode);
        System.out.println("channelCode=" + channelCode);
        System.out.println(jsonString);
        String parse = (String) JSONObject.parse(jsonString);
        System.out.println(parse);

        String s = "APP注册";
        String s1 = s.toLowerCase();
        System.out.println(s1);
    }

    @Test
    public void stringBufferTest() {
        StringBuilder content = new StringBuilder("scanVerbal").append("\n")
                .append("<a href=\"https://open.weixin.qq.com/connect/oauth2/authorize?appid=")
                .append("wx0cbb2c3e9475ec59")
                .append("&redirect_uri=http%3A%2F%2Fdoctor-public-account.cloudtest.swifthealth.cn%2F%23%2Fsuggest%2Fsuggest-detail")
                .append("&response_type=code&scope=snsapi_base&state=")
                .append("129").append("#wechat_redirect\">点此查看详情</a>");
        System.out.println(content);
    }

    @Test
    public void replaceTest() {
        String msgPhone = "13759961354".replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
        System.out.println(msgPhone);

        String replaceAll = "13759961354".replaceAll("(\\d{2})\\d{4}", "$1****");
        System.out.println(replaceAll);


        String s = "qrscene_123,qrscene_";
        s = s.replaceFirst("qrscene_", "");
        System.out.println(s);
    }
}
